﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Data.Entity;
using System.IO;


namespace LiveProjectManager.DDD
{
    public class EntityContextInitializer : DropCreateDatabaseAlways<EntityContext>
    {
        protected override void Seed(EntityContext myContext)
        {
            myContext.UserRepository.Add(new Domains.User { 
                UserName = "admin", 
                Email ="admin@test.test",
                Password = DDD.Services.UserService.encryptPassword("123"),
                FirstName = "John",
                LastName = "Doe",
                isManager = true,
                CreatedOn = DateTime.Now
            });
            myContext.UserRepository.Add(new Domains.User {
                UserName = "member",
                Email = "member@test.test",
                Password = DDD.Services.UserService.encryptPassword("1234"),
                FirstName = "Jane",
                LastName = "Roe",
                isManager = false,
                CreatedOn = DateTime.Now
            });


            myContext.ConfigRepository.Add(new Domains.Config
            {
                Key = "REPOSITORY_URL",
                Value = "http://svn.apache.org/repos/asf/spamassassin/trunk"
            });
            myContext.ConfigRepository.Add(new Domains.Config
            {
                Key = "REPOSITORY_LOCAL_PATH",
                Value = "SHARPSVN"
            });
            myContext.ConfigRepository.Add(new Domains.Config
            {
                Key = "RESOURCE_UPLOAD_PATH",
                Value = "uploads"
            });


            /*myPostService.create("Ceci est un post de test avec un commentaire.", myUserService.getById(1));
            myPostsCommentService.create("Voilà le commentaire", myUserService.getById(2), myPostService.getById(1));
            myPostService.create("Ceci est un post de sans commentaire.", myUserService.getById(1));
            myPostService.create("Ceci est un post de test avec deux commentaires.", myUserService.getById(1));
            myPostsCommentService.create("Voilà le premier commentaire", myUserService.getById(2), myPostService.getById(3));
            myPostsCommentService.create("Voilà le second commentaire", myUserService.getById(1), myPostService.getById(3));*/

            myContext.CategoryRepository.Add(new Domains.Category { 
                Name = "Documentation utilisateur",
                Description = "Ensemble de fichiers destinés à l'utilisateur final",
                CreatedOn = DateTime.Now
            });
            myContext.CategoryRepository.Add(new Domains.Category { 
                Name = "Documentation de développement",
                Description = "Ensemble de fichiers destinés à des sous-traitant",
                CreatedOn = DateTime.Now
            });
            myContext.CategoryRepository.Add(new Domains.Category { 
                Name = "Documentation technique",
                Description = "Ensemble de fichiers utilisés en interne pour le développement",
                CreatedOn = DateTime.Now
            });
        }
    }
}